package com.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dao.ContentsDao;
import com.pojo.Contents;
import com.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ContentsService extends ServiceImpl<ContentsDao, Contents> {

    @Autowired
    private ContentsDao contentsDao;

    /**
     * 分页查询app轮播
     * @param title  关键字
     * @param authorName  状态(0为禁用，1为启用)
     * @param page  页面
     * @param limit  条数
     * @return
     */
    public IPage selectshouye_lunbo(int page, int limit, String title, String authorName) {
        Page p = new Page(page, limit);
        QueryWrapper<Contents> query = new QueryWrapper();

        if(StringUtil.isNotNull(title)) {
            query.like("title" , title) ;
        }
        if(StringUtil.isNotNull(authorName)) {
            query.eq("admin_id" , authorName) ;
        }
        IPage iPage = contentsDao.selectPage(p, query);
        return iPage;
    }
}
